package com.yzy.exception;

import lombok.Getter;
import org.springframework.http.HttpStatus;

import java.util.Arrays;

@Getter
public class VisionException extends RuntimeException {
    private HttpStatus status;

    private Object data;

    private String message;

    private static final String RESPONSE_HANDLE_ERROR_MESSAGE = GlobalExceptionMessage.INTERNAL_SERVER_HANDLE_FAILED;

    public VisionException() {
        status = HttpStatus.EXPECTATION_FAILED;
        message = RESPONSE_HANDLE_ERROR_MESSAGE;
    }

    public VisionException(HttpStatus status, String message, Object... data) {
        super();
        this.status = status;
        this.message = message;
        if (data != null) this.data = Arrays.asList(data);
    }

    public VisionException(HttpStatus status, Exception e, Object... data) {
        super();
        this.status = status;
        this.message = RESPONSE_HANDLE_ERROR_MESSAGE;
        if (data != null) this.data = Arrays.asList(data);
        this.data = e.getMessage();
    }

    public HttpStatus getStatus() {
        return status;
    }

    public Object getData() {
        return data;
    }

    public String getMessage() {
        return message;
    }
}